home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
301-325
/
disk_319
/
cnewssrc
/
cnews.orig.lzh
/
libv7
/
getcwd.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-27
|
492b
|
31 lines
/*
* SystemV getcwd simulation, courtesy peter honeyman
*/
#include <stdio.h>
/* imports from libc */
extern FILE *popen();
extern char *rindex();
char *
getcwd(path, size)
register char *path;
int size;
{
register char *nlp;
register FILE *fp;
fp = popen("PATH=/bin:/usr/bin pwd", "r");
if (fp == NULL)
return 0;
if (fgets(path, size, fp) == NULL) {
(void) pclose(fp);
return 0;
}
if ((nlp = rindex(path, '\n')) != NULL)
*nlp = '\0';
(void) pclose(fp);
return path;
}